package thinkingJava.chapter13;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import java.util.regex.Pattern;

public class SimpleRead {
	public static BufferedReader input = new BufferedReader(
			new StringReader("Sir Robin of Camelot\n22 1.61803"));
	public static void main(String[] args) {
		try {
			System.out.println("what is your name");
			String name = input.readLine();
			System.out.println(name);
			System.out.println("How old are you? What is your favorite double?");
			System.out.println("input : <age> <double>");
			String numbers = input.readLine();
			System.out.println(numbers);
			String[] numArray = Pattern.compile(" ").split(numbers);
			int age = Integer.valueOf(numArray[0]);
			double favorite = Double.parseDouble(numArray[1]);
			System.out.format("Hi %s\n,", name);
			System.out.format("in fives years you will be %d .\n", age + 5);
			System.out.format("My favorite double is %f.\n",favorite / 2);
			int limit = 3;
			String f = String.format("%."+limit+"f", favorite / 2);
			System.out.println("f == " + f);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
